# 查询工具

def get_mobile(phone):
    url = f'https://www.ip138.com/mobile.asp?mobile={phone}&action=mobile'
    import requests
    from lxml import etree

    headers = {
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36'}

    resp = requests.get(url, headers=headers)
    resp.encoding = 'utf-8'

    e = etree.HTML(resp.text)

    # 提取数据
    datas = e.xpath('//tr/td[2]//text()')

    cleaned_datas = [item.strip() for item in datas if item.strip() != '']


    print(cleaned_datas)


get_mobile(13697351019)
